/**
 * render column overwrite querylist4ext.js
 * 
 * @param {}
 *            value
 * @param {}
 *            cellmeta
 * @param {}
 *            record
 * @param {}
 *            rowIndex
 * @param {}
 *            columnIndex
 * @param {}
 *            store
 * @return {}
 */
function renderHeader(value, cellmeta, record, rowIndex, columnIndex, store) {
	var fieldName = Ext.getCmp(querykey).getColumnModel()
			.getDataIndex(columnIndex);
	if (fieldName == 'LXCODE') {
		var resultString = String
				.format(
						'<b><a target="_blank" href="'
								+ context
								+ '/system/objectcreator.do?method=view&key=APP_LXDJ&id={0}">{1}</a></b>',
						record.data.ID, value);

		return resultString;
	} else if (fieldName == 'XFTIME' || fieldName == 'XJTIME') {
		return formatDate(value);
	} else if (fieldName == 'LXTYPE') {
		if (value == '0') {
			return '街乡';
		} else if (value == '1') {
			return '区';
		}
	}

	return value;
}

/**
 * 添加“过滤按钮”
 * 
 * @param {}
 *            grid
 */
function addMeMix(key) {
	var grid = Ext.getCmp(key);

	var tbar = grid.getTopToolbar();
	tbar.add('-', {
				text : '初审通过',
				iconCls : 'ftyes',
				handler : function() {
					doFt('1');
				}
			}

	);

	tbar.add('-', {
				text : '初审未通过',
				iconCls : 'ftno',
				handler : function() {
					doFt('-1');
				}
			}

	);

	function doFt(status) {
		var m = grid.getSelectionModel().getSelections();
		var ids;

		var label = '确定初审通过';

		if (status == '-1') {
			label = '确定初审不通过';
		}

		if (m.length > 0) {
			Ext.MessageBox.confirm('确认', label, function(btn) {
						doFtAction(btn, status);
					}, this);
		} else {
			Ext.MessageBox.alert('提示', '请选择来信案件！');
		}

		function doFtAction(btn) {
			if (btn == 'yes') {
				var m = grid.getSelectionModel().getSelections();
				for (var i = 0, len = m.length; i < len; i++) {
					if (i == 0) {
						ids = m[i].get('ID');
					} else {
						ids += ',' + m[i].get('ID');
					}
				}
				Ext.Ajax.request({
							url : context + '/app/ft.do?method=ft',
							waitMsg : '操作处理中...',
							method : 'POST',
							params : {
								ftstatus : status,// 来信或来访表
								'ids' : ids
							},
							success : function(form, action) {
								var sm = grid.getSelectionModel();
								if (sm.getCount() > 0) {
									sm.clearSelections();
								};
								grid.store.reload();
								Ext.Msg.alert('操作结束', '初审完成');
								// var obj =
								// Ext.util.JSON.decode(form.responseText); //
								// 返回的结果
								// alert(obj.info);
							},
							failure : function() {
								Ext.Msg.alert('', '初审失败');
							}
						});
			}
		}
	}
}